package com.hspedu.homework.homework8;

import java.text.SimpleDateFormat;
import java.util.Date;

public class BankAccount {
    private double balance;
    Date date = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    public BankAccount(double initialBalance) {
        this.balance = initialBalance;
    }

    //存款
    public void deposit(double amount) {
        balance += amount;
        date = new Date();
        System.out.println("存款成功\t" + "+" + amount + "\t" + sdf.format(date) + "\t余额\t" + getBalance());
    }

    public void withdraw(double amount) {
        balance -= amount;
        date = new Date();
        System.out.println("取款成功\t" + "-" + amount + "\t" + sdf.format(date) + "\t余额\t" + getBalance());

    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
